
<?php
	$c_id      = $_GET["id"];
	$sql       = "SELECT c_id,fname,lname,email,username,password,comments FROM clients WHERE c_id='$c_id'";
	$result    = mysql_query($sql) or die(mysql_error());
	$row       = mysql_fetch_assoc($result);
?>
<h3>Viewing <? echo $row["fname"]; ?> <? echo $row["lname"]; ?></h3>
<h4>Click fields to edit</h4>

<fieldset>
	<legend>Client Information</legend>
	<label>Name: </label>
	<span class="fname" id="fname__<? echo $row["c_id"]; ?>"><? echo $row["fname"]; ?></span> <span class="fname"><? echo $row["lname"]; ?></span><br />
	<label>Email: </label>
	<span class="email" id="email__<? echo $row["c_id"]; ?>"><? echo $row["email"]; ?></span><br />
</fieldset>
<fieldset>
	<legend>Intranet Login</legend>
	<label>Username: </label>
	<span class="username" id="username__<? echo $row["c_id"]; ?>"><? echo $row["username"]; ?></span><br />
	<label>Password: </label>
	<span class="password" id="password__<? echo $row["c_id"]; ?>"><? echo $row["password"]; ?></span><br />
</fieldset>
<fieldset>
	<legend>Other Comments and Notes</legend>
	<label>Notes: </label>
	<span class="comments" id="comments__<? echo $row["c_id"]; ?>"><? if($row["comments"] == ''){ echo "No notes, click to edit.";}else{echo $row["comments"];} ?></span><br />
</fieldset>

<h3>Projects</h3>

<table>
	<thead>
		<tr>
			<th>Project Title</th>
			<th>Date Started</th>
			<th>Project Category</th>
			<th>View</th>
		</tr>
	</thead>
	<tbody>
<?php
$sql    = "SELECT p_title,date_started,c_id,p_id,project_category.cat_title
		   FROM projects
		   INNER JOIN project_category ON projects.cat_id = project_category.cat_id 
		   WHERE c_id=".$row["c_id"]."";
		   
$query  = mysql_query($sql) or die(mysql_error());
while($row_project = mysql_fetch_array($query)){
	print '<tr>'; 
		print '<td>'.$row_project['p_title'].'</td>'; 
		print '<td>'.$row_project['date_started'].'</td>'; 
		print '<td>'.$row_project['cat_title'].'</td>'; 
		print '<td align="center"><a href="?c=view-client&id='.$row_project['p_id'].'" title="View Project Details"><img src="images/page_edit.png" alt="Edit entry!" /></a></td>';
	print '</tr>';
}
?>
	</tbody>
</table>